home *** CD-ROM | disk | FTP | other *** search
- function crtNewBall()
- {
- trace("crtNewBall 1.5:" + center_mc._currentframe);
- center_mc.gotoAndPlay(2);
- }
- function crt_new()
- {
- trace("crtNewBall 2.5");
- if(ball == undefined)
- {
- trace("产生新母球");
- if(tmp_ball_ball_type_arr != undefined)
- {
- center_mc.nextBall.type = tmp_ball_ball_type_arr[1];
- center_mc.nextBall2.type = tmp_ball_ball_type_arr[2];
- }
- var _loc2_ = center_mc.nextBall2.type;
- if(tgt_num >= tgt_totalNum && balls_num < 11)
- {
- while(type_num_array[_loc2_] == 0 && balls_num != 0)
- {
- _loc2_ = random(tgt_type) + 1;
- }
- }
- superBall = false;
- var _loc4_ = type_arr[random(type_arr.length)];
- var _loc5_ = _loc2_;
- ball = new Ball("attBall",0,center_mc._x,center_mc._y,_loc2_);
- _root.nowBall = ball;
- canShoot = true;
- shooting = false;
- set_ball_pos(pos_r,center_mc._rotation * AtoR);
- if(_root.jumpBall || _root.boomBall)
- {
- superBall = false;
- if(_root.boomBall)
- {
- _root.boomBall = false;
- }
- else if(_root.jumpBall)
- {
- _root.jumpBall = false;
- }
- PowerNum = 0;
- PowerMC.hong._x = -110;
- PowerMC.hong2._x = -110;
- }
- if(_root.holdBall == undefined || _root.holdBall2 == true && holdBall_mc.hold_mc != undefined && _loc2_ == 12 && hold_mx.num == 0 && heidong_vnt > 1)
- {
- type_arr = [7,9,8,12];
- }
- else
- {
- type_arr = [7,8,9];
- }
- if(_root.jumpBall || _root.boomBall || _root.holdBall)
- {
- if(_root.boomBall)
- {
- _root.boomBall = false;
- }
- else if(_root.jumpBall)
- {
- _root.jumpBall = false;
- }
- else if(_root.holdBall)
- {
- _root.holdBall = false;
- }
- PowerNum = 0;
- PowerMC.hong._x = -110;
- PowerMC.hong2._x = -110;
- }
- _loc2_ = random(tgt_type) + 1;
- if(tgt_num >= tgt_totalNum && balls_num < 11 || balls_num == 12)
- {
- while(type_num_array[_loc2_] == 0 && balls_num != 0)
- {
- _loc2_ = random(tgt_type) + 1;
- }
- }
- if(now_type_tmp_arr.length >= 0 && now_type_tmp_arr[0] != undefined)
- {
- var _loc3_ = random(now_type_tmp_arr.length);
- _loc2_ = now_type_tmp_arr[_loc3_];
- trace(" type = " + _loc2_ + "randomNumx = " + _loc3_ + " arr = " + now_type_tmp_arr + "============ddddddddddddddddddddddddddddffffffffffffffffff================");
- }
- if(PowerNum >= 8)
- {
- _loc2_ = _loc4_;
- PowerNum = 0;
- PowerMC.hong._x = -110;
- PowerMC.hong2._x = -110;
- }
- center_mc.nextBall2.type = center_mc.nextBall.type;
- center_mc.nextBall2.gotoAndStop(center_mc.nextBall.type);
- center_mc.nextBall.type = _loc2_;
- center_mc.nextBall.gotoAndStop(_loc2_);
- tmp_ball_ball_type_arr = [_loc5_,center_mc.nextBall.type,center_mc.nextBall2.type];
- trace(" tmp_ball_ball_type_arr = " + tmp_ball_ball_type_arr);
- }
- }
- function set_ball_pos(w, rada)
- {
- ball.x = center_mc._x + w * Math.cos(rada);
- ball.y = center_mc._y + w * Math.sin(rada);
- ball.holder._x = ball.x;
- ball.holder._y = ball.y;
- ball.holder.flower._rotation = center_mc._rotation;
- }
- function tgt_hitTest(obj)
- {
- if(ball_type_change)
- {
- ball_type_change = false;
- obj.type = tmp_ball_ball_type_arr[0];
- }
- if(obj.type == 10)
- {
- _root.jumpBall = true;
- }
- if(obj.type == 8)
- {
- _root.boomBall = true;
- }
- if(obj.type == 12)
- {
- _root.holdBall = true;
- }
- var _loc8_ = Math.floor(obj.y / grid_width);
- attachBall = undefined;
- var _loc2_ = 0;
- var _loc6_ = 31;
- for(var _loc7_ in tgt_mcs)
- {
- var _loc4_ = obj.x - tgt_mcs[_loc7_]._x;
- var _loc3_ = obj.y - tgt_mcs[_loc7_]._y;
- _loc2_ = Math.sqrt(_loc4_ * _loc4_ + _loc3_ * _loc3_);
- if(_loc2_ < 30 and _loc2_ <= _loc6_)
- {
- trace(_loc7_ + "+++++++++++++++++++hittest this mc");
- _loc6_ = _loc2_;
- attachBall = tgt_mcs[_loc7_];
- }
- }
- if(attachBall._currentframe > 12)
- {
- trace("AAA_currentframe" + tgt_mcs[_loc7_]._currentframe);
- attachBall.removeMovieClip;
- attachBall = undefined;
- }
- if(attachBall != undefined)
- {
- attachBall.shine.gotoAndPlay(2);
- insert_type = obj.type;
- if(attachBall.type == 11)
- {
- insert_type = obj.type;
- }
- trace(attachBall.type + "在这里插入碰状:" + insert_type + ":" + attachBall._currentframe);
- if(!superBall)
- {
- attach_sound.start(0);
- delete shoot_listener_mc.onEnterFrame;
- if(attachBall.type == 11)
- {
- tgt_insert_start(attachBall,"right");
- }
- else if(Math.atan2(obj.y - attachBall._y,obj.x - attachBall._x) % 360 <= Math.atan2(center_mc._y - attachBall._y,center_mc._x - attachBall._x) % 360)
- {
- tgt_insert_start(attachBall,"left");
- }
- else
- {
- tgt_insert_start(attachBall,"right");
- }
- }
- else
- {
- delete shoot_listener_mc.onEnterFrame;
- attach_sound.start(0);
- delete shoot_listener_mc.onEnterFrame;
- if(Math.atan2(obj.y - attachBall._y,obj.x - attachBall._x) % 360 <= Math.atan2(center_mc._y - attachBall._y,center_mc._x - attachBall._x) % 360)
- {
- tgt_insert_start(attachBall,"left");
- }
- else
- {
- tgt_insert_start(attachBall,"right");
- }
- trace("typetypetype:" + spSuperType);
- }
- }
- }
- function shoot(x, y)
- {
- trace(":::" + ball.holder);
- trace(":::" + ball);
- center_mc.gotoAndPlay("shoot");
- ball.holder.setMask(null);
- var _loc1_ = undefined;
- _loc1_ = shootSpeed / Math.sqrt(x * x + y * y);
- ball.dx = x * _loc1_;
- ball.dy = y * _loc1_;
- shoot_sound.start(0.1);
- if(dir_bool)
- {
- MballSD = 2;
- }
- else
- {
- MballSD = 1;
- }
- shoot_listener_mc.onEnterFrame = function()
- {
- if(!game_pause)
- {
- shootStep();
- }
- };
- }
- function shootStep()
- {
- ball.x += ball.dx * MballSD;
- ball.y += ball.dy * MballSD;
- crtShadow();
- if(ball.outOfScene())
- {
- clearBall();
- if(!m_lock)
- {
- crtNewBall();
- }
- }
- else if(mouth_start.pro_area.hitTest(ball.x,ball.y,true))
- {
- trace("源头保护,第一次");
- mouth_start.pro_area.gotoAndPlay(2);
- pro_sound.start(0);
- clearBall();
- if(!m_lock)
- {
- crtNewBall();
- }
- }
- else
- {
- tgt_hitTest(ball);
- }
- if(attachBall == undefined)
- {
- ball.x += ball.dx;
- ball.y += ball.dy;
- crtShadow();
- if(ball.outOfScene())
- {
- clearBall();
- if(!m_lock)
- {
- crtNewBall();
- }
- }
- else if(mouth_start.pro_area.hitTest(ball.x,ball.y,true))
- {
- trace("源头保护,第二次");
- mouth_start.pro_area.gotoAndPlay(2);
- pro_sound.start(0);
- clearBall();
- if(!m_lock)
- {
- trace("产生新球");
- crtNewBall();
- }
- }
- else
- {
- tgt_hitTest(ball);
- }
- }
- ball.holder._x = ball.x;
- ball.holder._y = ball.y;
- updateAfterEvent();
- }
- function center_rotation()
- {
- if(!m_lock && !drag_center)
- {
- var _loc1_ = Math.atan2(_ymouse - center_mc._y,_xmouse - center_mc._x);
- center_mc._rotation = _loc1_ * RtoA;
- if(!shooting)
- {
- set_ball_pos(pos_r,_loc1_);
- setMotherDir(_loc1_);
- }
- }
- }
- function ballShoot()
- {
- if(canShoot && !m_lock && ball != undefined)
- {
- shoot(_xmouse - center_mc._x,_ymouse - center_mc._y);
- shooting = true;
- canShoot = false;
- dir_mc.clear();
- }
- }
- function crtShadow()
- {
- if(ball_shadow && ball.holder != undefined)
- {
- ball_shadowID--;
- if(ball_shadowID <= 1)
- {
- ball_shadowID = 800;
- }
- if(!superBall)
- {
- ballScene.attachMovie("ball_shadow_mc","sh_mc" + ball_shadowID,ball_shadowID);
- ballScene["sh_mc" + ball_shadowID].c = new Color(ballScene["sh_mc" + ball_shadowID]);
- ballScene["sh_mc" + ball_shadowID].c.setRGB(flower_array[ball.type - 1]);
- }
- else
- {
- ballScene.attachMovie("superball_shadow_mc","sh_mc" + ball_shadowID,ball_shadowID);
- }
- ballScene["sh_mc" + ball_shadowID]._x = ball.x;
- ballScene["sh_mc" + ball_shadowID]._y = ball.y;
- }
- }
- shootSpeed = width * 0.6;
- sceneWidth = 600;
- sceneHeight = 450;
- grid_width = 60;
- pos_r = 36;
- Ball.init(ballScene,shootSpeed,sceneWidth,sceneHeight,width,20);
- xNum = Math.ceil(sceneWidth / grid_width);
- yNum = Math.ceil(sceneHeight / grid_width);
- center_mc.nextBall._visible = false;
- center_mc.nextBall.stop();
- center_mc.nextBall2._visible = false;
- center_mc.nextBall2.stop();
- m_lock = false;
- area = new Array();
- i = 0;
- while(i < xNum)
- {
- area[i] = new Array();
- j = 0;
- while(j < yNum)
- {
- area[i][j] = new Object();
- area[i][j].tgt_ball = new Array();
- j++;
- }
- i++;
- }
- myGrid = new Grid(grid_width,xNum,yNum,area);
- var spSuperType;
- type_arr = [7,8,9,12];
-